﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace HCMUTE_analysic.Models
{
    public class HcmuteAnalysicDbContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Permission> Permissions { get; set; }
        public DbSet<UserLevel> UserLevels { get; set; }
        public DbSet<UserAttempt> UserAttempts { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //config relationship here
            modelBuilder.Entity<User>()
            .HasOptional(q => q.UserAttempt);

            modelBuilder.Entity<UserAttempt>()
                            .HasRequired(qa => qa.User);
        }
        
    }
}